package com.java.demo.component;

import com.java.demo.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(50)   //控制注入的顺序 值越小权重越高
public class UserBeans {
    //当给 @bean 使用了重命名之后,那么默认的使用方法名获取对象的方式就不能使用了
    @Bean(name = {"user1","u1"})
    public User user1() {
        User user = new User();
        user.setUid(1);
        user.setName("张三");
        user.setPassword("123456");
        user.setAge(18);
        return user;
    }


    @Bean
    public User getuserbynamegetuserbyname() {
        User user = new User();
        user.setUid(2);
        user.setName("李四");
        user.setPassword("123456");
        user.setAge(20);
        return user;
    }
}
